#!/usr/bin/env python
# $Id: test2-58.py e501b84d8043 2013/07/05 07:47:14 pgurumur $
# Copyright (c) 2013 Prabhu Gurumurthy <pgurumur@gmail.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# File test2-58.py generated on Thursday July 04, 2013 @02:37:19 PDT
#
__version__  = "$Revision: e501b84d8043 $"
__author__   = "$Author: pgurumur $"
__modified__ = "$Date: 2013-07-05 07:47:14Z $"

import datetime
import jinja2
import sys
import os

from venya.lib import stdlib

def printdate(value = 0):
   return datetime.datetime.now().strftime("%a, %B %d, %Y %T %p")

def randstring(value = None):
   return stdlib.randstring(12)

if __name__ == "__main__":
   source = "test.j2"
   env = tmpl = None
   try:
      env = jinja2.Environment(loader = jinja2.FileSystemLoader(
         os.path.dirname(source)))
      env.filters['date'] = printdate
      env.filters['randstring'] = randstring
      tmpl = env.get_template(os.path.basename(source))
   except jinja2.exceptions.TemplateSyntaxError as err:
      print(err)
      sys.exit(1)
   except jinja2.exceptions.TemplateNotFound as err:
      print(err)
      sys.exit(1)
   else:
      print(tmpl.render({}))

